package com.jinzhi.jzweb.dao;

import com.baomidou.mybatisplus.plugins.Page;
import com.jinzhi.common.base.BaseDao;
import com.jinzhi.jzapi.certificate.pojo.ConsultationsVo;
import com.jinzhi.jzweb.domain.ConsultationsDO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 
 * <pre>
 * 资讯表
 * </pre>
 * <small> 2020-02-24 21:00:11 | lance</small>
 */
public interface ConsultationsDao extends BaseDao<ConsultationsDO> {

    @Select("SELECT id,first_column as firstColum,second_column as secondColumn,title,files,thumbnail,access_number as accessNumber,creater_date as createrDate " +
            " FROM jz_consultations where state=1 ORDER BY id desc")
    List<ConsultationsVo> dyGetUserList1(Page<ConsultationsVo> page);

    @Select("SELECT id,first_column as firstColum,second_column as secondColumn,title,files,thumbnail,access_number as accessNumber,creater_date as createrDate , " +
            "istop FROM jz_consultations where second_column=#{columnName} and first_column=#{firstColumn} and state=1 ORDER BY istop =1  desc  , creater_date desc")
    List<ConsultationsVo> dyGetUserList2(Page<ConsultationsVo> page, @Param("firstColumn") String firstColumn, @Param("columnName") String columnName);


    @Select("SELECT id,first_column as firstColum,second_column as secondColumn,title,files,thumbnail,access_number as accessNumber,creater_date as createrDate " +
            " FROM jz_consultations where first_column=#{firstColumn} and state=1 ORDER BY id desc")
    List<ConsultationsVo> dyGetUserList3(Page<ConsultationsVo> page, @Param("firstColumn") String firstColumn);


    @Select("SELECT id,first_column as firstColum,second_column as secondColumn,title,files,thumbnail,access_number as accessNumber,creater_date as createrDate " +
            " FROM jz_consultations where state=1 and thumbnail !='' ORDER BY id desc")
    List<ConsultationsVo> dyGetUserList4(Page<ConsultationsVo> page);

    @Select("SELECT id,first_column as firstColum,second_column as secondColumn,title,files,thumbnail,access_number as accessNumber,creater_date as createrDate " +
            " FROM jz_consultations where second_column=#{columnName} and first_column=#{firstColumn} and state=1 and thumbnail !='' ORDER BY id desc")
    List<ConsultationsVo> dyGetUserList5(Page<ConsultationsVo> page, @Param("firstColumn") String firstColumn, @Param("columnName") String columnName);


    @Select("SELECT id,first_column as firstColum,second_column as secondColumn,title,files,thumbnail,access_number as accessNumber,creater_date as createrDate " +
            " FROM jz_consultations where first_column=#{firstColumn} and state=1 and thumbnail !='' ORDER BY id desc")
    List<ConsultationsVo> dyGetUserList6(Page<ConsultationsVo> page, @Param("firstColumn") String firstColumn);

    @Select("SELECT c.id,first_column as firstColum,second_column as secondColumn,title,files,thumbnail,access_number as accessNumber,creater_date as createrDate , " +
            "istop FROM jz_consultations c "
            + "left join sys_role_consultations rc on c.id = rc.consultationsId "
            + "left join sys_user_role ur on rc.roleId =ur.roleId "
            + " where ur.userId=#{userId} and second_column=#{columnName} and first_column=#{firstColumn} and state=1 ORDER BY istop =1  desc  , creater_date desc")
    List<ConsultationsVo> dyGetUserList7(Page<ConsultationsVo> page, @Param("firstColumn") String firstColumn, @Param("columnName") String columnName,@Param("userId") Long userId);
    
    List<ConsultationsDO> findList (Page<ConsultationsDO> page, @Param("secondColumn") String secondColumn);

    //查询全部列表
    List<ConsultationsDO>  consultaionsListX();

    //修改成阿里云OSS路径
    int updateCertificateX(@Param("files") String files,@Param("id") String id,@Param("thumbnail") String thumbnail);
}
